package com.qf.entity;

/**
 * @author Wy
 * @version V1.0
 * @Project day41-3
 * @Package com.qf.entity
 * @Description:
 * @Date 2022/5/16 12:10
 */
public class Page {
    //页码, 当前页数
    private Integer pageIndex;
    //页大小  显示多少行数据
    private  Integer pageSize;
    //数据的总行数
    private  Integer  totaLCounts;
    //数据的总行数
    private  Integer  totalPages;
    //起始行, 从第几条开始查询 = (当前页数 - 1) * 每页显示数据条数
    private  Integer  startRows;


    public Page(Integer pageIndex) {
        this.pageIndex = pageIndex;
        //初始化每页显示条数, 默认每页显示5条数据
        this.pageSize=5;
    }

    public Page(Integer pageIndex, Integer pageSize) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        //初始化每页显示条数, 默认每页显示5条数据
        this.pageSize=5;
        //计算从第几条开始查询数据
       this.setStartRows((pageIndex-1)*pageSize);
    }


    public Page() {
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotaLCounts() {
        return totaLCounts;
    }

    public void setTotaLCounts(Integer totaLCounts) {
        this.totaLCounts = totaLCounts;
        //在设置总条数的时候, 顺便计算总页数
        this.setTotalPages(totaLCounts % pageSize==0 ? totaLCounts/pageSize:totaLCounts/pageSize +1);
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public Integer getStartRows() {
        return startRows;
    }

    public void setStartRows(Integer startRows) {
        this.startRows = startRows;
    }
}
